package com.foreknow.eldclient.controller;

import com.foreknow.eldclient.po.Food;
import com.foreknow.eldclient.po.OrderDetailet;
import com.foreknow.eldclient.service.FoodService;
import com.foreknow.eldclient.service.OrderDetailetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@ResponseBody
@RestController
@RequestMapping("FoodController")
public class FoodController {
    @Autowired
    private FoodService FS;
    @Autowired
    private OrderDetailetService ODS;

    @RequestMapping("/listFoodByBusinessId")
    public List<Food> listFoodByBusinessId(Integer businessId) throws Exception {
        return FS.listFoodByBusinessId(businessId);
    }

    @RequestMapping("/listFoodByFoodName")
    public List<Food> listFoodByFoodName(String foodName) throws Exception {
        return FS.listFoodByFoodName(foodName);
    }

    @RequestMapping("/addFoodByBId")
    public int addFoodByBId(Food food) {
        return FS.addFoodByBId(food);
    }

    @RequestMapping("/delFood")
    public int delFood(String foodId) {
        return FS.delFood(foodId);
    }


    @RequestMapping("/updateFoodById")
    public int updateFoodById(Food food) {
        return FS.updateFoodById(food);
    }

    @RequestMapping("/listFoodById")
    public Food listFoodById(int foodId) {
        return FS.listFoodById(foodId);
    }

    @RequestMapping("/updateFoodSalesByFId")
    public int updateFoodSalesByFId(OrderDetailet orderDetailet) throws Exception {
        return FS.updateFoodSales(orderDetailet);
    }

    @RequestMapping("/listTop5Food")
    public List<Food> listTop5Food() {
        return FS.listTop5Food();
    }



}
